# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=cargo-nextest
pkgver=0.9.82
pkgrel=0
pkgdesc="A next-generation test runner for Rust"
url="https://nexte.st/"
# s390x, ppc64le, loongarch64: no ring crate
arch="all !s390x !ppc64le !loongarch64"
license="Apache-2.0 OR MIT"
depends="cargo"
makedepends="
	cargo
	cargo-auditable
	zstd-dev
	"
source="https://github.com/nextest-rs/nextest/archive/cargo-nextest-$pkgver.tar.gz"
builddir="$srcdir/nextest-$pkgname-$pkgver"
options="net"  # integration tests need net

case "$CARCH" in
# Tests hang on CI.
riscv64) options="$options !check" ;;
esac

_cargo_opts="--frozen --no-default-features --features default-no-update"

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libzstd.
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		zstd = { rustc-link-lib = ["zstd"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build -p cargo-nextest $_cargo_opts --release
}

check() {
	cargo auditable build -p nextest-runner --bin passthrough --frozen

	# filter out tests that depend on running from a git checkout
	filterset='not (package(integration-tests) & (test(/^test_run_from_archive/) | test(=test_version_info)))'

	PATH="$PWD/target/release:$PWD/target/debug:$PATH" \
		cargo nextest run --profile ci -E "$filterset" $_cargo_opts
}

package() {
	install -D -m755 target/release/cargo-nextest -t "$pkgdir"/usr/bin/
}

sha512sums="
f01959deb09bf4b93b0262991881a4551759d4baeed4e37f8627b10b445db3b353d5031a9037cfb2da71af5b6165d5bff4c456ae526e7451073e571cdd481760  cargo-nextest-0.9.82.tar.gz
"
